<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html >
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${params.titlename}</title>
<link rel="stylesheet" href="/css/base/${params.prefixs}login.css" />
<script type="text/javascript" src="/js/base/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="/js/base/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/base/jquery.md5.js"></script>
<script type="text/javascript">
/**验证码重置 .*/
function resetfun(o) {
    o.src = "/login/getImage?"+Math.random();
}
/**登录验证.*/
function subfun(){
    var username = $("#username").val();
    var password = $("#password").val();
    var imageCode = $("#imageCode").val();
    if(username == null || username == ''){
		$('#ts').html("请您填写账号！");
		$('#ts').show();
	}else if(password == null || password == ''){
		$('#ts').html("请您填写密码！");
		$('#ts').show();
	}else if(imageCode == null || imageCode == ''){
		$('#ts').html("请您填写验证码！");
		$('#ts').show();
	}else{
		$.post("/login/check",{'username':username,'password':$.md5(password),'imageCode':imageCode},function(data){
			if(data == "no"){
				$('#ts').html("该用户已被禁用，请联系管理员！");
				$('#ts').show();
			}else if(data == "userError"){
				$("#ts").html("您输入的用户不存在！");
				$('#ts').show();
            }else if(data == "passwordError"){
            	$("#ts").html("输入密码错误，请重新登陆！");
				$('#ts').show();
            }else if(data == "imageCodeError"){
            	$("#ts").html("您输入的验证码不正确！");
				$('#ts').show();
            }else if(data == "typeError"){
            	$("#ts").html("用户密码错误~！");
				$('#ts').show();
            }else if(data == "statusError"){
            	$("#ts").html("该用户已被禁用，请联系管理员！");
				$('#ts').show();
            }else if(data == 'adminError'){
				$('#ts').html("后台程序关闭，请联系管理员!");
				$('#ts').show();
			}else if(data == "yes"){            	
            	rmbuser();
            	$('#ts').html("登录成功！");
				$('#ts').show();
            	$("#password").val($.md5(password));
            	document.getElementById("loginform").submit();
            }
		});
	}
}
//回车事件
document.onkeydown = function(e){
    var ev = document.all ? window.event : e;
    if(ev.keyCode==13) {
    	subfun();
    }
}

$(document).ready(function() {
	if('${isIE}' != 'true'){		
		if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Chrome") > 0) {
			
		} else {
			//window.location.href = "/login/error";
		}
	}
    if ($.cookie("host") == window.location.host) {
		$("#rmbuser").prop("checked", true);
		$("#username").val($.cookie("username"));
		$("#password").val($.cookie("password"));
	}
});
//记住用户名密码
function rmbuser() {
	if ($("#rmbuser").prop("checked")) {
		var username = $("#username").val();
		var password = $("#password").val();
		var host = window.location.host;
		$.cookie("host", host, {
			expires : 7
		}); //存储一个带7天期限的cookie
		$.cookie("username", username, {
			expires : 7
		});
		$.cookie("password", password, {
			expires : 7
		});
	} else {
		$.cookie("host", "-1", {
			expire : -1
		});
		$.cookie("username", "", {
			expires : -1
		});
		$.cookie("password", "", {
			expires : -1
		});
	}
};
</script>
</head>
<body>
    <div class="bg">
      <img src="../../img/login/${params.prefixs}bg.jpg" alt="mcaslogo" />
    </div>
    <div class="main">
    <div>
            <div class="lf" style="width:40%;">
            	<%-- <img src="../../img/login/${params.prefixs}logo.png" alt="" class="logo"/> --%><br><br><br><br><br><br><br><br><br><br>
            <div style="clear:both;"></div>
            <div style="width:331px;float:right;">
            	<h1 class="my_word">vcp</h1>
            	<p class="small_word">
					供应商平台
                </p>
                <!-- <h1 class="big_word">专注互联网程序化购买</h1> -->
                <!-- <p class="small_word">
                                                                             拥有国内明星媒体媒体资源最多的移动PMP平台和国内技术领先的移动DSP平台充分结合移动媒体大数据为基础的“迈可思DMP”数据管理平台,为广告主提供更精确的/更有效的数字营销服务，位媒体创造更多的广告收益。
                </p> -->
                
            </div>
        </div>
        <div class="rf" style="width:40%;">
            <p class="down" style="border:1px solid transparent;height:25px;line-height:25px;">
            	<span id="ts" style="display: none;font-size:15px;"></span>
            </p>
            <form action="/login/dologin" id="loginform" method="post">
            <input type="hidden" id="returl" name="returl" value="${returl}"/>
            <p class="right">
                <label class="emailicon"></label>
                <input id="username" name="username" type="text" placeholder="用户名" class="email"/>
            </p>
            <p class="right">
                <label class="passicon"></label>
                <input id="password" name="password" type="password" placeholder="密码" class="pass"/>
            </p>
            <p class="right">
                <label class="passtesticon"></label>
                <input id="imageCode" name="imageCode" type="text" placeholder="验证码" class="passtest"/>
                <img id="yzImage" title="点击更换" onclick="javascript:resetfun(this);" src="/login/getImage"/>
            </p>
            </form>
            <p class="right">
                <input id="rmbuser" type="checkbox"  class="rember_user"/><label class="rember_user_detail">记住用户名</label>
            </p>
            <p class="right">
                <input type="submit" class="LG" value="登 录" onclick="subfun()"/>
            </p>
             <p class="right">
                <a class="fleft" href="/login/forgetPassword">忘记密码?</a> <a href="/register" class="fright">立即注册</a>
            </p>
        </div>
    </div>
</div>
	<div class="footer">
	<div class="link">
		<a href="#">关于我们</a>
    	<a href="">|</a>
    	<a href="#">联系我们</a>
    	<a href="">|</a>
    	<a href="#">服务条款</a>
    	<a href="">|</a>
    	<a href="#">隐私政策</a>
    	<a href="">|</a>
    	<a href="#">常见问题</a>
    	<a href="">${params.ispn}</a>
	</div>
	</div>
</body>
</html>